import { ACTION_TYPE, IACTION, IState, ITodo } from "./typings";

function todoReducer(state: IState, action: IACTION): IState {
  const { type, payload } = action;

  switch (type) {
    case ACTION_TYPE.ADD_TODO:
      return { ...state, todoList: [...state.todoList, payload as ITodo] };
      break;

    default:
      return state
      break;
  }
}

export { todoReducer };
